var JsonGrid = cc.Sprite.extend({
    _directType : 0,
    ///////////////////////////////////////////////////////////
    ctor : function(filename,type){
        this._super(filename);
        this._directType = type;
    },
    rectOffset : function(d,factor){
        if(d==1||d==-1){
            return cc.p(factor *0.5,0);
        }else if( d==2||d==-2 ){
            return cc.p(-factor*0.5,0);
        }else if( d==3||d==-3 ){
            return cc.p(0,factor*0.5);
        }else if( d==4||d==-4 ){
            return cc.p(0,-factor*0.5);
        }
    },
    direct : function(){
        return this._directType;
    },
    collideRect:function (x, y) {
        var short=35,long=70;
        var dr = Math.abs(this._directType);
        switch(dr){
            case 1:{
                return cc.rect(x,y-long*0.5,short,long);
            }
            case 2:{
                return cc.rect(x-short,y-long*0.5,short,long);
            }
            case 3:{
                return cc.rect(x-long*0.5,y+short*0.5,long,short);
            }
            case 4:{
                return cc.rect(x-long*0.5,y-short*0.5,long,short);
            }
        }
    }
});


